package org.example.jwtdemo.utils;

import org.example.jwtdemo.entity.User;

public class ThreadLocalUtils {

    private ThreadLocalUtils() {
    }

    private static final ThreadLocal<User> threadLocal = new ThreadLocal<>();

    // 设置当前线程的User对象
    public static void set(User user) {
        threadLocal.set(user);
    }

    // 获取当前线程的User对象
    public static User get() {
        return threadLocal.get();
    }

    // 清除当前线程的User对象
    public static void remove() {
        threadLocal.remove();
    }

}
